package cn.ac.siom.query.util;

import cn.ac.siom.query.service.CountService;
import org.apache.log4j.Logger;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;

@Component
public class TaskSource {
    private Logger logger = Logger.getLogger(TaskSource.class);

    @Resource
    private CountService countService;


    @Scheduled(fixedRate  = 86400000) //如果你需要在特定的时间执行，就需要用到cron 了
    //这里是在每天的13点30分执行一次
    public void demo3() throws Exception {
        logger.info("定时任务demo3开始.");
        long begin = System.currentTimeMillis();
        //执行你需要操作的定时任务
        countService.findAllCount();
        long end = System.currentTimeMillis();
        logger.info("定时任务demo3结束，共耗时：[" + (end-begin)+ "]毫秒");
    }
}